package com.sf.dlb.service;

import com.sf.dlb.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created by tanjing on 2019/5/8.
 */
public class BaseService {

    @Autowired
    public RedisUtil redisUtil;
    /**
     * 是否并发操作
     * @return true=是 false=否
     */
    public boolean isConcurrent(String key){
        boolean existFlag=redisUtil.hasKey(key);
        if(existFlag){
            return true;
        }else{
            redisUtil.set(key,"1",2);//2秒内不能重复操作
            return false;
        }
    }

}
